import { defineConfig, loadEnv } from 'vite';
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite';
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
import { resolve } from 'path'
import qiankun from 'vite-plugin-qiankun';
import {fileURLToPath, URL} from "url";
// https://vitejs.dev/config/
export default ({mode}) => {
  return defineConfig({
    base: loadEnv(mode, process.cwd()).VITE_APP_URL || './',
    plugins: [
      vue(),
        Components({
            dts: true,
            resolvers: [AntDesignVueResolver()],
        }),
      qiankun('project', { useDevMode: true }),
    ],
    build:{
      outDir:'./dist'
    },
    //1.别名配置
      resolve: {
          alias: {
              '@': fileURLToPath(new URL('./src', import.meta.url)),
          },
      },
    /*resolve: {
      alias: [
        { find: '@', replacement: resolve(__dirname, 'src') },
      ],
    },*/
    css: {
      preprocessorOptions: {
        less: {
          javascriptEnabled: true,
        },
      },
    },
})
}


